<% tinymce_base_path = "#{Rails.application.config.assets.prefix}/tinymce" %>

<link rel="preload" href="<%= asset_path("#{tinymce_base_path}/skins/ui/alchemy/skin.min.css") %>" as="style" />
<% if Alchemy::Tinymce.init[:content_css] %>
  <link rel="preload" href="<%= asset_path(Alchemy::Tinymce.init[:content_css]) %>" as="style" />
<% end %>
<% Alchemy::Tinymce.preloadable_plugins.each do |plugin| %>
  <link rel="preload" href="<%= asset_path("#{tinymce_base_path}/plugins/#{plugin}/plugin.min.js") %>" as="script">
<% end %>

<script>
  // Setting TinyMCE path.
  var tinyMCEPreInit = {
    <% if ActionController::Base.config.asset_host %>
    base: '<%= asset_url(tinymce_base_path, host: ActionController::Base.config.asset_host) %>',
    <% else %>
    base: '<%= tinymce_base_path %>',
    <% end %>
    suffix: '.min'
  };
  // Holds the default Alchemy TinyMCE configuration
  Alchemy.TinymceDefaults = {
    plugins: '<%= Alchemy::Tinymce.plugins.join(',') %>',
    <% Alchemy::Tinymce.init.each do |k, v| %>
    <%= k %>: <%== v.to_json %>,
    <% end %>
  };
</script>
